package com.zksw.constant;

import com.zksw.utils.StringUtils;

/**
 * 订单常量
 *
 * @author mok
 */
public class OrderConstant {

	/**
	 * 订单类型
	 */
	public enum OrderType {

		NORMAL("1", "普通订单"), GROUP("2", "团购订单"), BARGAIN("3", "砍价订单");

		private String value;

		private String name;

		private OrderType(String value, String name) {
			this.value = value;
			this.name = name;
		}

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public static String getNameByValue(String value) {

			if (StringUtils.isNullOrEmpty(value)) {
				return "";
			}

			for (OrderType orderType : OrderType.values()) {
				if (orderType.value.equals(value)) {
					return orderType.name;
				}
			}

			return "";
		}
	}

	/**
	 * 订单状态
	 */
	public enum OrderStatus {

		WAIT_PAY(0, "待付款"), HAS_CANCELED(101, "订单已取消"), HAS_DELETED(102, "订单已删除"), HAS_PAYED(201, "订单已付款"), HAS_DELIVERED(300, "订单已发货"), HAS_RECEIVED(301, "用户确认收货"), FEFUND(
				401, "退款"), FINISHED(402, "完成");

		private int value;

		private String name;

		private OrderStatus(int value, String name) {
			this.value = value;
			this.name = name;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public static String getNameByValue(Integer value) {

			if (value == null) {
				return "";
			}

			for (OrderStatus orderStatus : OrderStatus.values()) {
				if (orderStatus.value == value) {
					return orderStatus.name;
				}
			}

			return "";
		}
	}

	/**
	 * 发货状态
	 */
	public enum ShippingStatus {

		WAIT_DELIVER(0, "未发货"), HAS_DELIVER(1, "已发货"), HAS_RECEIVED(2, "已收货"), HAS_RETURNED(4, "退货");

		private int value;

		private String name;

		private ShippingStatus(int value, String name) {
			this.value = value;
			this.name = name;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public static String getNameByValue(Integer value) {

			if (value == null) {
				return "";
			}

			for (ShippingStatus shippingStatus : ShippingStatus.values()) {
				if (shippingStatus.value == value) {
					return shippingStatus.name;
				}
			}

			return "";
		}
	}

	/**
	 * 付款状态
	 */
	public enum PayStatus {

		WAIT_PAYED(0, "未付款"), PAYING(1, "付款中"), HAS_PAYED(2, "已付款");

		private int value;

		private String name;

		private PayStatus(int value, String name) {
			this.value = value;
			this.name = name;
		}

		public int getValue() {
			return value;
		}

		public void setValue(int value) {
			this.value = value;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public static String getNameByValue(Integer value) {

			if (value == null) {
				return "";
			}

			for (PayStatus payStatus : PayStatus.values()) {
				if (payStatus.value == value) {
					return payStatus.name;
				}
			}

			return "";
		}
	}

}
